PROJECT(nuclear)

# Set the Nuclear SDK version
SET(NUCLEAR_MAJOR_VERSION 0)
SET(NUCLEAR_MINOR_VERSION 0)

SET(NUCLEAR_PACKAGE nuclear)
SET(NUCLEAR_VERSION ${NUCLEAR_MAJOR_VERSION}.${NUCLEAR_MINOR_VERSION})
SET(NUCLEAR_HOST ${CMAKE_SYSTEM} ${CMAKE_SYSTEM_PROECESSOR})
SET(NUCLEAR_COPYRIGHT "Copyright (c) 2008, Anders Dahnielson & Darren Landrum.")
SET(NUCLEAR_INSTALL_PREFIX ${CMAKE_INSTALL_PREFIX})
SET(NUCLEAR_LIBDIR lib${LIB_SUFFIX})

# Setup testing
ENABLE_TESTING()
#MARK_AS_ADVANCED(BUILD_TESTING)

# Detect 32/64 bit platform type
#MESSAGE(STATUS "checking the width of std::vector<>::size_type for this platform")

#TRY_RUN(
#  NUCLEAR_PLATFORM_SIZE_TYPE
#  NUCLEAR_PLATFORM_SIZE_TYPE_COMPILE
#  ${CMAKE_CURRENT_BINARY_DIR}
#  ${CMAKE_CURRENT_SOURCE_DIR}/configuration/size_type.cpp)

#MESSAGE(STATUS "  std::vector<>::size_type is ${NUCLEAR_PLATFORM_SIZE_TYPE} bits")

#IF(NUCLEAR_PLATFORM_SIZE_TYPE EQUAL 32)
#  SET(NUCLEAR_UINT_T_32_BITS 1)
#ELSEIF(NUCLEAR_PLATFORM_SIZE_TYPE EQUAL 64)
#  SET(NUCLEAR_UINT_T_64_BITS 1)
#ELSE(NUCLEAR_PLATFORM_SIZE_TYPE EQUAL 32)
#  MESSAGE(SEND_ERROR "Error detecting platform word-size.")
#ENDIF(NUCLEAR_PLATFORM_SIZE_TYPE EQUAL 32)

# Finding FAUST
IF(NOT FAUST_EXECUTABLE)
  MESSAGE(STATUS "Looking for FAUST")
  FIND_PROGRAM(FAUST_EXECUTABLE faust)
  IF(FAUST_EXECUTABLE)
    MESSAGE(STATUS "Looking for FAUST -- ${FAUST_EXECUTABLE}")
  ENDIF(FAUST_EXECUTABLE)
ENDIF(NOT FAUST_EXECUTABLE)

# Macro for generating C++ from DSP files...
IF(FAUST_EXECUTABLE)
  MACRO(FAUST_FILE FILENAME)
    GET_FILENAME_COMPONENT(PATH "${FILENAME}" PATH)
    GET_FILENAME_COMPONENT(HEAD "${FILENAME}" NAME_WE)
    SET(OUTFILE "${CMAKE_CURRENT_SOURCE_DIR}/${HEAD}.dsp.in")
    ADD_CUSTOM_COMMAND(
      OUTPUT "${OUTFILE}"
      COMMAND "${FAUST_EXECUTABLE}"
      ARGS -o ${OUTFILE}
      "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}"
      DEPENDS "${CMAKE_CURRENT_SOURCE_DIR}/${FILENAME}")
    SET_SOURCE_FILES_PROPERTIES("${OUTFILE}" PROPERTIES GENERATED TRUE)
  ENDMACRO(FAUST_FILE)
ENDIF(FAUST_EXECUTABLE)

# Build shared libraries
SET(BUILD_SHARED_LIBS ON)

# Set up dubdirectories...
ADD_SUBDIRECTORY(docs)
ADD_SUBDIRECTORY(sdk)
#IF(BUILD_TESTING)
ADD_SUBDIRECTORY(tests)
#ENDIF(BUILD_TESTING)
